﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/User.Master" Inherits="System.Web.Mvc.ViewPage<SDT.Site.Areas.User.ViewModels.DemandInputModels>" %>

<%@ Import Namespace="SDT.Lib.Helpers" %>
<%@ Import Namespace="SDT.Lib.Paging" %>
<%@ Import Namespace="SDT.Site.Areas.User.ViewModels" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Thêm tin cần mua/thuê
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <%if (ViewData["MessageInfo"] == null)
      { %>
    <% using (Html.BeginForm("Create", "Demand", FormMethod.Post, new { id = "adminForm" }))
       {%>
    <%= Html.ValidationSummary(true)%>

        <table class="admintable" width="100%">
            <tbody>
                   <tr>
                        <td class="key" style="width:150px">
                            Loại nhu cầu (<font color="red">*</font>)
                        </td>
                        <td>
                            <%=Html.DropDownListFor(m=>m.Demand.DemandTypeID, new SelectList(Model.DemandTypes,"ID","Name"), "-- Loại nhu cầu --", new { @class="required" })%>
                        </td>
                    </tr>
                    <tr>
                        <td class="key">
                            Phân mục (<font color="red">*</font>)
                        </td>
                        <td>
                            <%=Html.DropDownListFor(m=>m.Demand.CatID, new SelectList(Model.Categories,"ID","Name"), "-- Chuyên mục --", new { @class="required" })%>
                        </td>
                    </tr>
                    <tr>
                        <td class="key">
                            Tỉnh/Thành phố(<font color="red">*</font>)
                        </td>
                        <td>
                            <%=Html.DropDownListFor(m=>m.Demand.CityID, new SelectList(Model.ListCity,"ID","Name"), "-- Tỉnh/Thành phố --", new { @class="required" })%>
                        </td>
                    </tr>
                    <tr>
                        <td class="key">
                            Quận/Huyện (<font color="red">*</font>)
                        </td>
                        <td>
                            <%=Html.DropDownListFor(m => m.Demand.DistrictID, new SelectList(Model.ListDistrict, "ID", "Name"), "-- Quận/Huyện --", new {@class = "required"})%>
                        </td>
                    </tr>
                    <tr>
                        <td class="key">
                            Tiêu đề (<font color="red">*</font>)
                        </td>
                        <td>
                            <%=Html.TextBoxFor(m => m.Demand.Title, new { style = "width: 500px; height:22px;", @class = "required" })%>
                        </td>
                    </tr>
                    <tr>
                        <td class="key">
                            Mô tả
                        </td>
                        <td>
                            <%=Html.TextAreaFor(m => m.Demand.Description, new { style="width: 500px; height:150px" })%>
                        </td>
                    </tr>
                    <tr>
                        <td class="key">
                            Số tầng
                        </td>
                        <td>
                            <%=Html.TextBoxFor(m => m.Demand.Floors, new { style = "width: 50px;height:22px; text-align: center;" })%>
                        </td>
                    </tr>
                    <tr>
                        <td class="key">
                            Số phòng
                        </td>
                        <td>
                            <%=Html.TextBoxFor(m => m.Demand.Rooms, new { style = "width: 50px;height:22px; text-align: center;" })%>
                        </td>
                    </tr>
                    <tr>
                        <td class="key">
                            Giá(<font color="red">*</font>)
                        </td>
                        <td>
                            <%=Html.TextBoxFor(m => m.Demand.Cost, new { style = "width: 100px;height:22px; text-align: center;", @class = "required number" })%>
                            <%=Html.DropDownListFor(m=>m.Demand.CurrencyID,new SelectList(Model.ListCurrency,"Key","Value").ToList())%>
                            <%=Html.DropDownListFor(m=>m.Demand.UnitCostID, new SelectList(Model.ListUnitCost,"Key","Value").ToList())%>
                        </td>
                    </tr>
                    <tr>
                        <td class="key">
                            Diện tích(<font color="red">*</font>)
                        </td>
                        <td>
                            <%=Html.TextBoxFor(m => m.Demand.Area, new { style = "width: 100px;height:22px; text-align: center;", @class = "required number" })%>m2
                        </td>
                    </tr>
                    <tr>
                        <td class="key">Số ngày đăng</td>
                        <td><%=Html.DropDownList("ExpireDateTime",new SelectList (Model.ListExpireDate,"Key","Value").ToList(),"-- Số ngày đăng tin --", new {@class="required"} )%></td>
                    </tr>
            </tbody>
        </table>
        <table class="admintable" width="100%">
            <tr>
                <td class="key" style="width:150px">
                    Họ tên
                </td>
                <td>
                    <%=Html.TextBoxFor(m => m.Demand.ContactName, new { style = "width: 500px;height:22px" })%>
                </td>
            </tr>
            <tr>
                <td class="key">
                    Địa chị
                </td>
                <td>
                    <%=Html.TextBoxFor(m => m.Demand.ContactAddress, new { style = "width: 500px;height:22px;" })%>
                </td>
            </tr>
            <tr>
                <td class="key">
                    Mobile
                </td>
                <td>
                    <%=Html.TextBoxFor(m => m.Demand.ContactMobile, new { style = "width: 500px;height:22px" })%>
                </td>
            </tr>
            <tr>
                <td class="key">
                    Skype
                </td>
                <td>
                    <%=Html.TextBoxFor(m => m.Demand.ContactSkyper, new { style = "width: 500px;height:22px" })%>
                </td>
            </tr>
            <tr>
                <td class="key">
                    Yahoo
                </td>
                <td>
                    <%=Html.TextBoxFor(m=>m.Demand.ContactYahoo, new { style = "width: 500px;height:22px"})%>
                </td>
            </tr>
         </table>
        <div style="display:block; text-align:center">
            <input id="btnSubmit" type="submit" value="Thêm mới" name="btnSubmit"/>
        </div>

    <%}
      } %>

    <script type="text/javascript">
        $(document).ready(function() {           
            $("#adminForm").validate();

            $("#Demand_CityID").unbind("change").change(function() {
                var val = $("#Demand_CityID").val();
                if (val == "" || val == '' || val == undefined)
                    return false;
                AjaxChange("#Demand_CityID", "#Demand_DistrictID", "/AjaxData/LoadDistrictByCity/");
            });
        });

        var fileIndex = 1;
        var hash = { '.jpg': 1, '.png': 1, '.gif': 1, '.doc': 1, '.docx': 1, '.xls': 1, '.xlsx': 1, '.zip': 1, '.rar': 1, '.ppt': 1, '.pptx': 1, '.txt:': 1 };
        function check_extension(filename, submitId) {
            var re = /\..+$/;
            var ext = filename.match(re).toString().toLowerCase();
            var submitEl = document.getElementById(submitId);
            if (hash[ext]) {
                submitEl.disabled = false;
                return true;
            } else {
            }
        }
    </script>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="Toolbar" runat="server">
    <td>
    <%= Html.Toolbar("Quay về", "Demand", "back") %>
    </td>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="Header" runat="server">
    Thêm tin cần mua/thuê
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="Message" runat="server">
    <%=ViewData["MessageInfo"]!=null? "<p class='perror'>"+Html.Encode(ViewData["MessageInfo"])+"</p>":string.Empty%>
</asp:Content>
